package com.download.backstage.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.download.web.entity.BusArticleComment;
import com.download.web.service.IBusArticleCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

@Controller
@RequestMapping("/backstage/comm")
public class CommentController {
    @Autowired
    private IBusArticleCommentService articleCommentService;

    @RequestMapping("/selectAllList")
    public String selectAllList(@RequestParam(value = "states",defaultValue = "0")Integer states,@RequestParam(value = "pageIndex",defaultValue = "1") Integer pageIndex,@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, Model model){
        Map<String,Object> map=articleCommentService.selectAllList(pageIndex, pageSize,states);
        model.addAttribute("commentList",map);
        return "backstage/comment";
    }

    @RequestMapping("/pingbi")
    public String pingbi(int id){
        BusArticleComment comm=articleCommentService.getOne(new QueryWrapper<BusArticleComment>().eq("id",id));
        comm.setStates(!comm.getStates());
        Boolean pan=articleCommentService.updateById(comm);
        return "redirect:/backstage/comm/selectAllList";
    }
}
